package com.aitou.mrylive.presentation.ui.main.find;

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.Html;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.aitou.mrylive.R;
import com.aitou.mrylive.data.bean.HotAreaBean;
import com.aitou.mrylive.domain.LocalDataManager;
import com.aitou.mrylive.presentation.ui.base.BaseActivity;
import com.aitou.mrylive.presentation.ui.main.find.adapter.ImageGridAdapter;
import com.aitou.mrylive.presentation.ui.main.find.adapter.ReplyAdapter;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.DongTaiDetailActivity;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.DongTaiDetailBean;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.DongTaiListBean;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.DongtaiPresenter;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.MyDongTaiBean;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.PublishBean;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.PublishInterFace;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.PublishPresenter;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.WodeDongtaiActivity;
import com.aitou.mrylive.presentation.ui.main.me.OtherUserActivity;
import com.aitou.mrylive.presentation.ui.widget.UserInfoDialog;
import com.aitou.mrylive.util.Const;
import com.aitou.mrylive.util.DensityUtil;
import com.aitou.mrylive.util.ReplyPopupWindow;
import com.aitou.mrylive.util.XImageLoader;

import java.util.ArrayList;
import java.util.List;

import chatemoji.FaceInputView;

/**
 * Created by admin on 2016/9/12.
 */
public class PengYouQuanActivity extends BaseActivity implements PublishInterFace, View.OnClickListener, XListView.IXListViewListener {
    private List<HotAreaBean> list = new ArrayList<>();
    private XListView mRecyclerView;
    private PengYouQuanAdapter placeRecycleAdapter;
    private TextView myFaBu;
    private DongtaiPresenter dongtaiPresenter;
    private List<DongTaiListBean.DongTaiItem> array = new ArrayList<>();
    public RelativeLayout bottom;
    ReplyPopupWindow mReplyPup;
    EditText input_edit;
    PublishPresenter publishpresenter;
    private String pid = null;//回复动态
    private String rid = null;//回复回复
    private PopupWindow mMorePopupWindow;
    int type;
    private View parentView;
    private AlertDialog alertDialog;
    private boolean isShow;
    private FaceInputView faceInputView;
    private LinearLayout faceInputContainer;
    ImageView emoji,img_back;
    private PengYouQuanAdapter adapter;
    int pageNO = 1;
    public static String REFRESHLIST="refresh_dongtai";
    private String isLike=null;
    private UserInfoDialog dialog;
    private String mTargetId;

    public static Intent createIntent(Context context) {
        return new Intent(context, PengYouQuanActivity.class);
    }

    @Override
    protected int getLayoutId() {
        parentView = LayoutInflater.from(this).inflate(R.layout.activity_goodsfriends_message, null);
        return R.layout.activity_goodsfriends_message;
    }

    @Override
    protected void findViews(Bundle savedInstanceState) {

        IntentFilter intentFilter=new IntentFilter(REFRESHLIST);
        registerReceiver(receiver,intentFilter);
        adapter = new PengYouQuanAdapter(array);
        mRecyclerView = (XListView) findViewById(R.id.goodfriends_recyler);
        mRecyclerView.setAdapter(adapter);
        img_back= (ImageView) findViewById(R.id.img_back);
        img_back.setOnClickListener(this);
        mRecyclerView.setPullRefreshEnable(true);
        mRecyclerView.setPullLoadEnable(true);
        mRecyclerView.setXListViewListener(this);
        mReplyPup = new ReplyPopupWindow(PengYouQuanActivity.this, this);
        View reply = mReplyPup.getContentView();
        input_edit = (EditText) reply.findViewById(R.id.input_edit);
        faceInputContainer = (LinearLayout) reply.findViewById(R.id.faceInputContainer);
        emoji = (ImageView) reply.findViewById(R.id.emoji);
        emoji.setOnClickListener(this);

        bottom = (RelativeLayout) findViewById(R.id.bottom);
        dongtaiPresenter = new DongtaiPresenter(this);
        publishpresenter = new PublishPresenter(this);

        pageNO = 1;
        dongtaiPresenter.getDongTaiList(LocalDataManager.getInstance().getLoginInfo().getToken(), pageNO + "", "10");


//        placeRecycleAdapter =new PengYouQuanAdapter(this,list,commentClickListener);
//        mRecyclerView.addItemDecoration(new RecycleViewDivider(
//        this, LinearLayoutManager.VERTICAL, 10, getResources().getColor(R.color.gray)));//添加分割线
        myFaBu = (TextView) findViewById(R.id.myFaBu);
        myFaBu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(PengYouQuanActivity.this, WodeDongtaiActivity.class);
                startActivity(intent);
            }
        });
        mRecyclerView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (array != null) {
                    if (array.size() > 0) {
                        Intent intent = new Intent(PengYouQuanActivity.this, DongTaiDetailActivity.class);
                        intent.putExtra("pid", array.get(position - 1).getPid());
                        startActivity(intent);
                    } else {

                    }
                } else {

                }
            }
        });
        faceInputView = new FaceInputView(this);
        faceInputContainer.addView(faceInputView);
        faceInputView.setOnClickListener(new FaceInputListenr());
////        mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
////        mRecyclerView.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.VERTICAL));
//        mRecyclerView.setAdapter(placeRecycleAdapter);
    }

    //通过广播通知删除后更新界面
    BroadcastReceiver receiver=new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            dongtaiPresenter.getDongTaiList(LocalDataManager.getInstance().getLoginInfo().getToken(),pageNO+"","10");
        }
    };

    @Override
    public void onRefresh() {
        pageNO = 1;

        dongtaiPresenter.getDongTaiList(LocalDataManager.getInstance().getLoginInfo().getToken(), pageNO + "", "10");
    }

    @Override
    public void onLoadMore() {
        pageNO++;
        dongtaiPresenter.getDongTaiList(LocalDataManager.getInstance().getLoginInfo().getToken(), pageNO + "", "10");
    }

    public void stopLoad() {
        mRecyclerView.stopRefresh();
        mRecyclerView.stopLoadMore();
    }

    private class FaceInputListenr implements FaceInputView.OnFaceClickListener {

        @Override
        public void selectedFace(FaceInputView.Face face) {
            int id = face.faceId;
            if (id == R.drawable.ic_face_delete_normal)// 删除按钮
            {
                int index = input_edit.getSelectionStart();
                if (index == 0)
                    return;
                Editable editable = input_edit.getText();
                editable.delete(index - 1, index);// 删除最后一个字符或表情
            } else {
                input_edit.append(Html.fromHtml("<img src='" + id + "'/>",
                        imageGetter, null));// 添加表情
            }
        }

    }


    // 输入表情需要
    Html.ImageGetter imageGetter = new Html.ImageGetter() {
        @Override
        public Drawable getDrawable(String source) {
            int id = Integer.parseInt(source);
            @SuppressWarnings("deprecation")
            Drawable d = getResources().getDrawable(id);
            d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
            return d;
        }
    };

    @Override
    protected void init() {

    }

    @Override
    public void showPublishResult(PublishBean data) {

    }

    @Override
    public void showUpdatePublishResult(String data) {

    }

    @Override
    public void showDeletePublishResult(String data) {
        if (data != null) {
            Toast.makeText(this, "删除帖子成功", 0).show();
        } else {
            Toast.makeText(this, "操作失败,请刷新后重试!", 0).show();
        }
    }

    @Override
    public void showdianzanResult(String data) {
        if (data != null) {
            if(isLike!=null) {
                if(isLike.equals("0")) {
                    Toast.makeText(this, "点赞成功", 0).show();
                }
                else{
                    Toast.makeText(this, "取消点赞成功", 0).show();
                }
            }else{
                Toast.makeText(this, "数据有误", 0).show();
            }
            dongtaiPresenter.getDongTaiList(LocalDataManager.getInstance().getLoginInfo().getToken(), pageNO + "", "10");
        } else {
            Toast.makeText(this, "操作失败,请刷新后重试!", 0).show();
        }
    }

    @Override
    public void showDongtaiList(DongTaiListBean data) {
        if (data != null) {
            DongTaiListBean bean = data;
            if (bean != null) {
                if (bean.getList() != null) {
                    if (pageNO == 1) {
                        array.clear();
                    }
                    array.addAll(bean.getList());
                    adapter.notifyDataSetChanged();
                }
            }
        }
        try {
            stopLoad();
        } catch (Exception e) {

        }
    }

    @Override
    public void showMyDongTaiList(List<MyDongTaiBean> list) {

    }

    @Override
    public void getDetailData(DongTaiDetailBean bean) {

    }

    @Override
    public void showHuiFuOneResult(PublishBean result) {
        if (result != null) {
            if (result.getRid() != null) {
                Toast.makeText(this, "操作成功!", 0).show();
                dongtaiPresenter.getDongTaiList(LocalDataManager.getInstance().getLoginInfo().getToken(), "1", "10");
            }
        }
    }

    @Override
    public void showReplyDeleteResult(String result) {
        if (result != null) {
            Toast.makeText(this, "删除成功!", 0).show();
        } else {
            Toast.makeText(this, "删除失败!", 0).show();
        }
    }

    @Override
    public void getReplyList(DongTaiListBean.DongTaiItem.ReplyList data) {

    }

    @Override
    public void getDianZanList(DongTaiListBean.DongTaiItem.ReplyList data) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_send://发送评论消息
                dismisipopup();
                String content = input_edit.getText().toString();
                if (content.equals("")) {
                    Toast.makeText(this, "请输入有效内容", 0).show();
                    return;
                }
                if (pid == null && type == 0) {
                    Toast.makeText(this, "当前内容有误，请刷新后重试!", 0).show();
                    return;
                }
                if (rid == null && type == 1) {
                    Toast.makeText(this, "当前内容有误，请刷新后重试!", 0).show();
                    return;
                }
                comment(type == 0 ? pid : rid, Spanned2String.parse(input_edit.getText()), type);
                break;
            case R.id.emoji://显示表情
                if (!isShow) {
                    faceInputContainer.setVisibility(View.VISIBLE);
                } else {
                    faceInputContainer.setVisibility(View.GONE);
                }
                isShow = !isShow;

                break;
            case R.id.img_back:
                finish();
                break;
            case R.id.re_dianzan://点赞
                dismisipopup();

                if(isLike!=null){
                    if(isLike.equals("0")){
                        publishpresenter.dianzan(LocalDataManager.getInstance().getLoginInfo().getToken(), pid, "1");
                    }else{
                        publishpresenter.dianzan(LocalDataManager.getInstance().getLoginInfo().getToken(), pid, "0");
                    }
                }


                break;
            case R.id.re_comment://

                mMorePopupWindow.dismiss();
                if (!mReplyPup.isShowing())
                    mReplyPup.showAtLocation(
                            parentView,
                            Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
//                else{
//                    mReplyPup.dismiss();
//                }
                break;
            case R.id.delete:
                if (rid == null) {
                    Toast.makeText(this, "当前内容有误，请刷新后重试!", 0).show();
                    return;
                }
                publishpresenter.replyDelete(LocalDataManager.getInstance().getLoginInfo().getToken(), rid);
                if (alertDialog != null) {
                    alertDialog.dismiss();
                }
                break;
            case R.id.cancel:
                if (alertDialog != null) {
                    alertDialog.dismiss();
                }
                break;
            case R.id.my_me_photo:
                startActivity(OtherUserActivity.createIntent(this,
                        Integer.parseInt(v.getTag()+""), false));
                break;
        }
//        if (v.getId() != R.id.emoji && v.getId() != R.id.re_comment) {
//            rid = null;
//            pid = null;
//        }
    }
    boolean m=false;



    public class PengYouQuanAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {

        List<DongTaiListBean.DongTaiItem> list;


        public PengYouQuanAdapter(List<DongTaiListBean.DongTaiItem> list) {
            this.list = list;
        }

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {

            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            Holder holder = null;
            if (convertView == null) {
                holder = new Holder();
                convertView = LayoutInflater.from(PengYouQuanActivity.this).inflate(R.layout.item_circle_friends, parent, false);
                holder.item_billboard_name = (TextView) convertView.findViewById(R.id.item_billboard_name);
                holder.item_billboard_contant = (TextView) convertView.findViewById(R.id.item_billboard_contant);
                holder.item_friend_time = (TextView) convertView.findViewById(R.id.item_friend_time);
                holder.my_me_photo = (ImageView) convertView.findViewById(R.id.my_me_photo);
                holder.item_goodfriends_tag1 = (ImageView) convertView.findViewById(R.id.item_billboard_tag1);
                holder.item_goodfriends_tag2 = (ImageView) convertView.findViewById(R.id.item_billboard_tag2);
                holder.item_friend_commentimg = (ImageView) convertView.findViewById(R.id.item_friend_commentimg);
                holder.li_imgContainer = (MyGridView) convertView.findViewById(R.id.li_imgContainer);
                holder.comment_listView = (MyListView) convertView.findViewById(R.id.comment_listView);
                holder.waiceng = (RelativeLayout) convertView.findViewById(R.id.waiceng);
                holder.li_fav_container = (FixGridLayout) convertView.findViewById(R.id.li_fav_container);
                convertView.setTag(holder);
            } else {
                holder = (Holder) convertView.getTag();
            }
            holder.item_billboard_name.setText(list.get(position).getNickname() == null ? "初来乍到" : list.get(position).getNickname());
            holder.item_billboard_contant.setText(String2Spanned.parsed(list.get(position).getContent()));

//            holder.item_billboard_contant.setTag(v.get);
            holder.item_friend_time.setText(list.get(position).getDateline());
            if(list.get(position).getAvatar()!=null) {
                if(list.get(position).getAvatar().endsWith(".jpg")) {
                    XImageLoader.load(Const.IMAG_NEW_URL + list.get(position).getAvatar(), holder.my_me_photo);
                }else{
                    XImageLoader.load(Const.IMAG_NEW_URL + list.get(position).getAvatar() + ".jpg", holder.my_me_photo);
                }
            }
            holder.my_me_photo.setTag(list.get(position).getUid());
            holder.my_me_photo.setOnClickListener(PengYouQuanActivity.this);

            if(list.get(position).getSex()!=null){
                if(list.get(position).getSex().equals("0")){
                    holder.item_goodfriends_tag1.setBackgroundResource(R.drawable.ic_female);
                }else {
                    holder.item_goodfriends_tag1.setBackgroundResource(R.drawable.ic_male);
                }
            }
            if(list.get(position).getLevel()!=null){
                if(list.get(position).getLevel().size()>0){
                    holder.item_goodfriends_tag2.setBackgroundResource(R.drawable.rank_+Integer.parseInt(list.get(position).getLevel().get(0).getLevelid()));
                }
            }
            if (list.get(position).getReply() != null) {
                if (list.get(position).getReply().getList() != null) {
                    holder.comment_listView.setAdapter(new ReplyAdapter(position, list.get(position).getReply().getList(), PengYouQuanActivity.this));
                    holder.comment_listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int innerposition, long id) {
                            if(((TextView)view.findViewById(R.id.tv_content)).getText().equals("查看更多>>")){
                                Intent intent = new Intent(PengYouQuanActivity.this, DongTaiDetailActivity.class);
                                intent.putExtra("pid", array.get(position).getPid());
                                intent.putExtra("uid",array.get(position).getUid());
                                startActivity(intent);
                                return;
                            }
                            Toast.makeText(PengYouQuanActivity.this, array.get(position).getReply().getList().get(innerposition).getRid(), 0).show();
                            if (LocalDataManager.getInstance().getLoginInfo().getUserId().equals(array.get(position).getReply().getList().get(innerposition).getUid())) {

                                alertDialog = new AlertDialog.Builder(PengYouQuanActivity.this).create();
                                alertDialog.show();
                                Window window = alertDialog.getWindow();
                                window.setContentView(R.layout.alert_delete);
                                TextView tv_delete = (TextView) window.findViewById(R.id.delete);
                                tv_delete.setGravity(Gravity.CENTER);
                                tv_delete.setText("删除");
                                tv_delete.setOnClickListener(PengYouQuanActivity.this);
                                TextView tv_message = (TextView) window.findViewById(R.id.cancel);
                                tv_message.setText("取消");
                                tv_message.setOnClickListener(PengYouQuanActivity.this);
                            } else{
                                type = 1;
                                if (!mReplyPup.isShowing())
                                    mReplyPup.showAtLocation(
                                            parentView,
                                            Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
//                                bottom.setVisibility(View.VISIBLE);
                            }
                            rid = array.get(position).getReply().getList().get(innerposition).getRid();

                        }
                    });
                } else {
                    holder.comment_listView.setVisibility(View.GONE);
                }
            } else {
                holder.comment_listView.setVisibility(View.GONE);
            }
            holder.li_fav_container.removeAllViews();
            int width = DensityUtil.dip2px(40);
            int height = DensityUtil.dip2px(40);
            if (list.get(position).getLikes() != null) {
                if (list.get(position).getLikes().getList() != null) {
                    if (list.get(position).getLikes().getList().size() > 0) {
                        holder.waiceng.setVisibility(View.VISIBLE);
                        for (int i = 0; i < list.get(position).getLikes().getList().size(); i++) {
                            TextView text = new TextView(PengYouQuanActivity.this);
                            text.setTextColor(getResources().getColor(R.color.md_pink_600));

                            text.setText(list.get(position).getLikes().getList().get(i).getNickname());
                            if(i==0) {
                                Drawable drawable = getResources().getDrawable(R.drawable.undianzan);//这一步必须要做,否则不会显示.
                                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                                text.setCompoundDrawables(drawable, null, null, null);
                                text.setCompoundDrawablePadding(3);
                            }
                            LinearLayout.LayoutParams layoutparamas = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                            layoutparamas.setMargins(5, 5, 5, 5);
                            text.setLayoutParams(layoutparamas);
                            holder.li_fav_container.addView(text);
                        }
                    } else {
                        holder.waiceng.setVisibility(View.GONE);
                    }

                } else {
                    holder.waiceng.setVisibility(View.GONE);
                }
            } else {
                holder.waiceng.setVisibility(View.GONE);
            }
            if (list.get(position).getPics() != null) {
                if (list.get(position).getPics().length > 0) {
                    holder.li_imgContainer.setVisibility(View.VISIBLE);
                    ImageGridAdapter adapter = new ImageGridAdapter(PengYouQuanActivity.this, list.get(position).getPics());
                    holder.li_imgContainer.setAdapter(adapter);
                } else {
                    holder.li_imgContainer.setVisibility(View.GONE);
                }

            } else {
                holder.li_imgContainer.setVisibility(View.GONE);
            }
            holder.item_friend_commentimg.setTag(position);
            holder.item_friend_commentimg.setTag(R.id.tag_3, array.get(position).getIslike());
            holder.item_friend_commentimg.setTag(R.id.tag_2, array.get(position).getPid());
            holder.item_friend_commentimg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    int y=v.getBottom();
                    type = 0;
                    pid = v.getTag(R.id.tag_2) + "";//获取pid
                    isLike = v.getTag(R.id.tag_3) + "";
                    showMorePopup(v);
                }
            });
            return convertView;
        }

        //回复列表点击  进行回复
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//            Toast.makeText(PengYouQuanActivity.this,array.get(parent.getSelectedItemPosition()).getContent(),0).show();
//            String uid=LocalDataManager.getInstance().getLoginInfo().getUserId();

//            bottom.setVisible(View.VISIBLE);
        }

        //    内部类holder
        public class Holder {
            //        private TextView mTitile, mNumber;
            ImageView my_me_photo, item_goodfriends_tag1, item_goodfriends_tag2, item_friend_commentimg;
            TextView item_billboard_name, item_billboard_contant, item_friend_time;
            MyGridView li_imgContainer;
            RelativeLayout waiceng;
            MyListView comment_listView;
            FixGridLayout li_fav_container;
            private ImageView mImg;
        }
    }

    /***
     * 显示点赞 评论窗体
     *
     * @param view
     */

    public void showMorePopup(View view) {
        LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View content = li.inflate(R.layout.popup_commentorfav, null, false);

        mMorePopupWindow = new PopupWindow(content, ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        mMorePopupWindow.setBackgroundDrawable(new BitmapDrawable());
        mMorePopupWindow.setOutsideTouchable(true);
        mMorePopupWindow.setTouchable(true);

        content.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        int mShowMorePopupWindowWidth = content.getMeasuredWidth();
        int mShowMorePopupWindowHeight = content.getMeasuredHeight();

        View parent = mMorePopupWindow.getContentView();

        RelativeLayout re_dianzan = (RelativeLayout) parent.findViewById(R.id.re_dianzan);
        TextView txt_dianzan= (TextView) parent.findViewById(R.id.txt_dianzan);
        if(isLike!=null) {
            if(isLike.equals("0")){
                txt_dianzan.setText("点赞");
            }else{
                txt_dianzan.setText("取消");
            }
        }
        re_dianzan.setOnClickListener(this);
        RelativeLayout re_comment = (RelativeLayout) parent.findViewById(R.id.re_comment);
        re_comment.setOnClickListener(this);
        if (mMorePopupWindow.isShowing()) {
            mMorePopupWindow.dismiss();
        } else {
            int heightMoreBtnView = view.getHeight();

            mMorePopupWindow.showAsDropDown(view, -mShowMorePopupWindowWidth,
                    -(mShowMorePopupWindowHeight + heightMoreBtnView) / 2);
        }
    }

    public void dismisipopup() {
        if (mMorePopupWindow != null) {
            if (mMorePopupWindow.isShowing())
                mMorePopupWindow.dismiss();
        }
    }

    public void comment(String id, String content, int type) {
        if (type == 0) {//回复动态
            publishpresenter.replyOne(LocalDataManager.getInstance().getLoginInfo().getToken(), id, content);
        } else {//回复回复
            publishpresenter.replyTwo(LocalDataManager.getInstance().getLoginInfo().getToken(), id, content);
        }
    }
}
